using System;
using System.Windows;

namespace LarkShot
{
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            
            // 确保只有一个实例运行
            var processes = System.Diagnostics.Process.GetProcessesByName("LarkShot");
            if (processes.Length > 1)
            {
                MessageBox.Show("LarkShot 已经在运行中！", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                Shutdown();
                return;
            }

            var mainWindow = new MainWindow();
            MainWindow = mainWindow;
            
            // 启动时隐藏到托盘
            mainWindow.WindowState = WindowState.Minimized;
            mainWindow.Show();
            mainWindow.Hide();
        }
    }
}
